﻿<UserControl x:Class="Berico.SnagL.Infrastructure.Modularity.Toolbar.GraphGeneratorToolbarItemExtensionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
    xmlns:convertors="clr-namespace:Berico.Common.UI.Converters;assembly=Berico.Common"             
    mc:Ignorable="d"
    d:DesignHeight="35" d:DesignWidth="35">
    
    <!-- TODO: SWITCH TO USE THEME -->
    <UserControl.Resources>
        <convertors:VisibilityConverter x:Key="VisibilityConverter" />
        
        <Style x:Key="ButtonStyle" TargetType="Button">
            <Setter Property="IsEnabled" Value="true"/>
            <Setter Property="IsTabStop" Value="true"/>
            <Setter Property="Background" Value="#FFA9A9A9"/>
            <Setter Property="Foreground" Value="#FF000000"/>
            <Setter Property="MinWidth" Value="5"/>
            <Setter Property="MinHeight" Value="5"/>
            <Setter Property="Margin" Value="0"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Cursor" Value="Hand"/>
            <!--<Setter Property="TextAlignment" Value="Left"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>-->
            <Setter Property="FontSize" Value="10" />
            <!--<Setter Property="FontWeight" Value="Bold" />-->
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid>
                            <Grid.Resources>
                                <LinearGradientBrush x:Key="ButtonBorderGradient" EndPoint="0.5,1" StartPoint="0.5,0">
                                    <GradientStop Color="#FF4F4F4F"/>
                                    <GradientStop Color="#FF464646" Offset="1"/>
                                </LinearGradientBrush>
                                <SolidColorBrush x:Key="DisabledBrush" Color="#A5FFFFFF"/>
                            </Grid.Resources>
                            <vsm:VisualStateManager.VisualStateGroups>
                                <vsm:VisualStateGroup x:Name="CommonStates">
                                    <vsm:VisualStateGroup.Transitions>
                                        <vsm:VisualTransition GeneratedDuration="0:0:0.2" To="Pressed"/>
                                    </vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualState x:Name="Normal" >
                                        <Storyboard/>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Pressed">
                                        <Storyboard>
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#33FFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#66FFFFFF"/>
                                            </ColorAnimationUsingKeyFrames>
                                            <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="BackgroundGradient" Storyboard.TargetProperty="(Border.Background).(GradientBrush.GradientStops)[0].(GradientStop.Offset)">
                                                <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.05"/>
                                            </DoubleAnimationUsingKeyFrames>
                                            <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)">
                                                <SplineColorKeyFrame KeyTime="00:00:00" Value="#FF000000"/>
                                            </ColorAnimationUsingKeyFrames>
                                        </Storyboard>
                                    </vsm:VisualState>
                                    <vsm:VisualState x:Name="Disabled">
                                        <Storyboard>
                                            <DoubleAnimation Storyboard.TargetName="DisabledVisual" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="0" To=".55"/>
                                        </Storyboard>
                                    </vsm:VisualState>
                                </vsm:VisualStateGroup>
                            </vsm:VisualStateManager.VisualStateGroups>
                            <Border x:Name="Background" BorderBrush="Transparent" BorderThickness="1" CornerRadius="5" Background="#FFA9A9A9" />
                            <Border x:Name="BackgroundGradient" BorderBrush="{StaticResource ButtonBorderGradient}" BorderThickness="1" CornerRadius="5" >
                                <Border.Background>
                                    <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                        <GradientStop Color="#FCFFFFFF"/>
                                        <GradientStop Color="#4CFFFFFF" Offset="1"/>
                                    </LinearGradientBrush>
                                </Border.Background>
                            </Border>
                            <ContentPresenter x:Name="Content" Margin="4,5,4,4" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" />
                            <Path x:Name="DisabledVisual" Fill="{StaticResource DisabledBrush}" Opacity="0" StrokeMiterLimit="1.000000" Data="F1 M 130.916504,120.166992 C 130.916504,126.793945 125.543457,132.166992 118.916504,132.166992 L 12.500000,132.166992 C 5.872559,132.166992 0.500000,126.793945 0.500000,120.166992 L 0.500000,12.500000 C 0.500000,5.872559 5.872559,0.500000 12.500000,0.500000 L 118.916504,0.500000 C 125.543457,0.500000 130.916504,5.872559 130.916504,12.500000 L 130.916504,120.166992 Z" Stretch="Fill" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
    </UserControl.Resources>

    <Button Style="{StaticResource ButtonStyle}" Command="{Binding ItemSelected}" Width="35" Height="35" IsEnabled="{Binding IsEnabled, Mode=TwoWay}" Visibility="{Binding IsVisible, Converter={StaticResource VisibilityConverter}}">
        <ToolTipService.ToolTip>
            <ToolTip Content="{Binding Description}" />
        </ToolTipService.ToolTip>
    </Button>  

</UserControl>
